import { url } from '@/config';
// var request = window.axios;
import request from '@/router/axios';

let VisualType = "ThreeD";


export const getList = (params = {}) => request({
    url: url + '/Visual/List',
    method: 'get',
    params: Object.assign(params, {
        VisualType: VisualType
    })
});


export const copyObj = (id) => request({
    url: url + '/Visual/Copy',
    method: 'post',
    params: {
        ID: id,
        VisualType: VisualType
    }
});

export const getCategory = (params = {}) => request({
    url: url + '/Category/List',
    method: 'get',
    params: Object.assign(params, {
        VisualType: VisualType
    })
});

export const getObj = (id) => request({
    url: url + '/Visual/Detail',
    method: 'get',
    params: {
        ID: id,
        VisualType: VisualType
    }
});
export const uploadImg = (file) => request({
    url: url + '/Visual/PutFile',
    method: 'post',
    data: 'file=' + file,
    headers: { "Content-Type": "multipart/form-data" }
});

export const addObj = (data = {}) => request({
    url: url + '/Visual/Add',
    method: 'post',
    data: {
        Visual: {
            Password: data.password,
            Category: parseInt(data.category),
            Status: parseInt(data.status),
            Title: data.title,
        },
        Config: {
            Detail: JSON.stringify({
                name: data.title,
                width: data.width,
                height: data.height,
                scale: 1,
                backgroundImage: '/img/bg/bg1.png',
                url: '',
                mark: {},
                gradeShow: false,
                gradeLen: 30,
            }),
            Component: '[]'
        },
        VisualType: VisualType,
        isPortal: data.isPortal
    }
});

export const updateComponent = (data = {}) => request({
    url: url + '/Visual/Edit',
    method: 'post',
    data: Object.assign(data, {
        VisualType: VisualType
    })
});

export const updateObj = (data) => request({
    url: url + '/Visual/Edit',
    method: 'post',
    data: {
        "Visual": {
            "ID": data.id,
            "Password": data.password,
            "Category": parseInt(data.category),
            "Status": parseInt(data.status),
            "Title": data.title,
        },
        VisualType: VisualType
    }
});

export const delObj = (id) => request({
    url: url + '/Visual/Delete',
    method: 'post',
    params: {
        ID: id,
        VisualType: VisualType
    }
});

export const uploadZip = (data) => request({
    url: url + '/Import',
    method: 'post',
    data: data,
    headers: { "Content-Type": "multipart/form-data" }
});

